package com.pjs.tdd;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.when;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

import com.pjs.test.framework.AbstractUnitTestCase;

public class SimpleTransactionReferenceTest extends AbstractUnitTestCase<SimpleTransactionReference> {
	
	private final String id="id";
	private @Mock ReferenceGenerator referenceGenerator; 

	public SimpleTransactionReferenceTest() {
		super(SimpleTransactionReference.class);
	}
	
	@Before
	public void setup(){
		when(referenceGenerator.nextReference()).thenReturn(id);
		classUnderTest.setReferenceGenerator(referenceGenerator);
		classUnderTest.build();
	}
	
	@Test
	public void transactionReferenceConstructedWithDateAndId(){
		assertNotNull("transaction reference should have date populated",classUnderTest.date());
		assertEquals("id should have been set by ReferenceGenerator",id, classUnderTest.id());
	}
	
}
